
import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/8/15
 * Time:15:44
 **/
public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String n = sc.nextLine();//int会报错
            String str = sc.nextLine();
            String[] s = str.split(" ");
            int[] coins = new int[s.length];
            for (int i = 0; i < coins.length; i++) {
                coins[i] = Integer.parseInt((s[i]));
            }
            int amount = Integer.parseInt(n);
            System.out.println(change(amount, coins));
        }
    }
    public static int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int coin : coins) {
            for (int i = coin; i <= amount; i++) {
                dp[i] += dp[i - coin];
            }
        }
        return dp[amount];
    }
}